import datetime
from typing import Literal

from pydantic import BaseModel, Field
from .object_id import ObjectId, MyObjectId


class BaseItem(BaseModel):
    class Config:
        allow_population_by_field_name = True
        arbitrary_types_allowed = True
        json_encoders = {ObjectId: str}


class BaseInsertItem(BaseItem):
    """定义数据结构的基类"""
    id: MyObjectId = Field(default_factory=MyObjectId, alias="_id")
    is_del: Literal[0, 1] = 0
    create_time: datetime.datetime = datetime.datetime.now()
    update_time: datetime.datetime = datetime.datetime.now()
